<?php
/**
 * Desc：Demo
 * Author：Fly
 * DateTime：2020/9/12 9:40
 */
namespace root;

require_once '../vendor/autoload.php';

use FlyToper\PearBackend\Header;
use FlyToper\PearBackend\headers\Basic;
use FlyToper\PearBackend\headers\CkField;
use FlyToper\PearBackend\Table;

class Demo
{
    public $static_path = "../frontend/pear-admin";

    //列表查询
    public function index()
    {
        $table = new Table();
        $header = new Header([
            'ck' => (new CkField('ck')),
            'id' => 'ID',
            'name' => (new Basic('name', '姓名'))->width(100),
        ]);



        $table_str = $table->setHeader($header)->render();

        return $table_str;
    }

    //表单：新增 or 编辑
    public function form()
    {
        return 'form';
    }

    //post请求，保存
    public function post()
    {

    }

}

$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : 'index';

$obj = new Demo();
echo $obj->{$act}();

